#ifndef __NONAME_DIR_H__
#define __NONAME_DIR_H__

#define NONAME_LIB_USE

#include <ntifs.h>
#include "nm_mem.h"
#include "nm_string.h"

class kdirectory {
public:
	kdirectory();
	void Release();
	
	VOID Close();
	NTSTATUS Create(
		kstringw& FileName, 
		ULONG  CreateDisposition = FILE_OPEN, 
		ACCESS_MASK DesiredAccess = GENERIC_READ, 
		ULONG ShareAccess = FILE_SHARE_READ
		);
	NTSTATUS Create(
		PWCHAR FileName, 
		ULONG  CreateDisposition = FILE_OPEN, 
		ACCESS_MASK DesiredAccess = GENERIC_READ, 
		ULONG ShareAccess = FILE_SHARE_READ
		);
	NTSTATUS Create(
		PUNICODE_STRING FileName, 
		ULONG  CreateDisposition = FILE_OPEN, 
		ACCESS_MASK DesiredAccess = GENERIC_READ, 
		ULONG ShareAccess = FILE_SHARE_READ
		);
	NTSTATUS Delete(BOOLEAN Del = TRUE);
	HANDLE GetHandle();
	NTSTATUS GetName(kstringw& String);
	PFILE_OBJECT GetObject();
	NTSTATUS GetPath(kstringw& String);
	NTSTATUS GetPath(PFILE_NAME_INFORMATION NameInfo, ULONG Length);
	NTSTATUS MakeDir(PUNICODE_STRING FileName);
	NTSTATUS MakeDir(kstringw& FileName);
	NTSTATUS MakeDir(PWCHAR FileName);
	NTSTATUS QueryDir(
		PVOID FileInformation, 
		ULONG Length, 
		PUNICODE_STRING FileName = NULL, 
		FILE_INFORMATION_CLASS FileInformationClass = FileBothDirectoryInformation, 
		BOOLEAN ReturnSingleEntry = TRUE
		);
	NTSTATUS Rename(PFILE_RENAME_INFORMATION RenameInfo, ULONG Length);
	NTSTATUS Rename(kstringw& Name, BOOLEAN ReplaceIfExists = FALSE);

	static BOOLEAN IsDirectory(kstringw& String);
	static BOOLEAN IsDirectory(PUNICODE_STRING UniString);
	static BOOLEAN IsDirectory(PWCHAR String);

private:
	HANDLE m_filehandle;
	PFILE_OBJECT m_fileobj;

};

#endif